home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
- Subject: Re: Seek unix2dos.c OR help with tr
- Date: 11 Mar 1996 06:39:47 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4i16uj$kr@solutions.solon.com>
- References: <4i0946$7io@nuke.csu.net> <10MAR199622434233@erich.triumf.ca>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <10MAR199622434233@erich.triumf.ca>,
- P.Bennett <bennett@erich.triumf.ca> wrote:
- >You should declare c as int, not char, since getchar() returns an int, and EOF
- >is a negative int, outside the range that can be represented by a char.
-
- Nit: EOF may be representable as a char, if char is signed. This is ok,
- since getc, fgetc, and getchar all return the next char *as an unsigned char*
- or EOF.
-
- Worse, the test won't work if sizeof(int) == 1 and all char values are
- possible. This is rare, but may actually happen somewhere. (Before anyone
- gets confused, sizeof(char) is definitionally 1, and a machine with 16 bit
- or larger chars could have int and char the same size. sizeof is not defined
- in terms of 8 bit bytes.)
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-